//
//  YTSeatTypeViewController.m
//  YiTuDriverClient
//
//  Created by 石少庸 on 2017/7/11.
//  Copyright © 2017年 Yitu. All rights reserved.
//

#import "YTSeatTypeViewController.h"
#import "YTDriverCarServices.h"
#import "YTCarBandTypeModel.h"

@interface YTSeatTypeViewController ()
@property (strong, nonatomic) NSArray<YTBandVersionModel *> *dataArray;
@end

@implementation YTSeatTypeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    _dataArray = [NSArray array];
    [[YTDriverCarServices carSeatType] subscribeNext:^(NSDictionary *response) {
        NSDictionary *dict = response[@"responseData"];
        _dataArray = [NSArray yy_modelArrayWithClass:[YTBandVersionModel class] json:dict[@"seatTypeList"]];
        [self.tableView reloadData];
    }];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"YTSeatTypeView" forIndexPath:indexPath];
    cell.textLabel.text = _dataArray[indexPath.row].name;
    return cell;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return _dataArray.count;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    if (_callBack) {
        _callBack(_dataArray[indexPath.row]);
        [self.navigationController popViewControllerAnimated:YES];
    }
}

@end
